<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE>
<html>
   <head>
   	   <meta charset="utf8">
   	   <meta name="viewport" content="width=device-width, initial-scale=1">
       <link rel="stylesheet" type="text/css" href="/aquaticproduct/Public/css/bootstrap.min.css">
       <link rel="stylesheet" type="text/css" href="/aquaticproduct/Public/css/sticky-footer-navbar.css">
       <script type="application/javascript" src="/aquaticproduct/Public/js/jquery-1.11.1.min.js"></script>
       <script type="application/javascript" src="/aquaticproduct/Public/js/bootstrap.min.js"></script>
   	   <title>水产品质量溯源系统</title>

   </head>
<body>
    <!-- Fixed navbar -->
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container">
	        <div class="navbar-header">
	          <button type="button" class="navbar-toggle" data-toggle="collapse" 
		         data-target="#navbar">
		         <span class="sr-only">切换导航</span>
		         <span class="icon-bar"></span>
		         <span class="icon-bar"></span>
		         <span class="icon-bar"></span>
		      </button>
	          <a class="navbar-brand" href="<?php echo U('Home/Index/iindex');?>">水产品质量溯源系统</a>
	        </div>
	        <div id="navbar" class="collapse navbar-collapse" >
	          <ul class="nav navbar-nav">
	            <li class="dropdown">
	            	<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">个人中心<span class="caret"></span></a>
	            	   <ul class="dropdown-menu">
		                <li><a href="<?php echo U('Home/User/showMe',array('role'=> '3'));?>">个人信息</a></li>
		                <li ><a href="<?php echo U('Home/Index/logout');?>" style="color:red">退出</a></li>	
		              </ul>
	            </li> 

	            <li class="dropdown">
	              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">功能列表 <span class="caret"></span></a>
	              <ul class="dropdown-menu">
	                <li><a href="<?php echo U('Home/Safe/index');?>">养殖基本信息</a></li>
					<li><a href="<?php echo U('Home/Safe/cultivation', array('name'=>'stocking'));?>">养殖管理</a></li>
	                <li><a href="#">出塘管理</a></li>
	                <li><a href="#">质量追溯</a></li>	                
	              </ul>
	            </li>
	              <li><a href="<?php echo U('Home/Test/test', array('name' => 'qrcode'));?>">自动化录入信息</a></li>
	          </ul>
	        </div><!--/.nav-collapse -->
      </div>
    </nav>
    
    <div class="container">
    	<div class="row">
    		<div class="col-sm-9">
    		  
	<div class="row">
	 
		   	<table class="table table-bordered table-striped col-sm-12" >
		     <caption>基地信息:</caption>
			     <thead>
			        <tr>
			           <th>基地名称</th>
			           <th>地理位置</th>
			           <th>水质来源</th>
			           <th>基地规模</th>
			           <th>联系人</th>
			           <th>联系电话</th>
			        </tr>
			     </thead>
			     <tbody>
			        <tr>
			           <td><?php echo ($base_data['base_name']); ?></td>
			           <td><?php echo ($base_data['base_addr']); ?></td>
			           <td><?php echo ($base_data['base_source_water']); ?></td>
	                   <td><?php echo ($base_data['base_scale']); ?></td>
			           <td><?php echo ($base_data['base_contacts']); ?></td>
			           <td><?php echo ($base_data['base_tel']); ?></td>
			           
			        </tr>
			     </tbody>
	 		 </table>
	  
	</div> <!-- row --><hr>
	<div class="row">
		<table class="table table-bordered table-striped col-sm-12" >
	     <caption>池塘信息:</caption>
		     <thead>
		        <tr>	        	
		           
		           <th>池塘名称</th>
		           <th>池塘位置</th>
		           <th>经纬度列表</th>
		           <th>水面面积</th>
		           <th>水面深度</th>	
		           <th>养殖设施设备</th>
		           <th>养殖模式</th>
		           <th>操作</th>
		           
		        </tr>
		     </thead>
		     <tbody>
			        <tr>
			           <td><?php echo ($pool_data["pool_name"]); ?></td>
			           <td><?php echo ($pool_data["pool_addr"]); ?></td>
			           <td><?php echo ($pool_data["pool_coordinate"]); ?></td>
			           <td><?php echo ($pool_data["pool_area"]); ?></td>
			           <td><?php echo ($pool_data["pool_depth"]); ?></td>
			           <td><?php echo ($pool_data["pool_equipment"]); ?></td>
			           <td>
				          <button class="btn btn-info" data-toggle="tooltip" data-placement="bottom" title="对应网箱信息如下"><?php echo ($pool_data["pool_model"]); ?></button>
			           </td>
			          
			           <td><button class="btn btn-danger" data-toggle="modal" data-target="#modifyPoolModal" id="modifyButton" value="<?php echo ($pool_data["pool_id"]); ?>" onclick="change(this)">修改</button></td>
			        </tr>
		     </tbody>
 		 </table>
	</div><hr>
	  <?php if($pool_data['pool_model'] == '网箱'): ?><div class="row">
	      <button class="btn btn-lg btn-primary"  data-toggle="modal" data-target="#addCageModal">添加网箱</button>
		   	<table class="table table-bordered table-striped col-sm-12" >
		     <caption>网箱信息:</caption>
			     <thead>
			        <tr>
			           <th>网箱排编号</th>
			           <th>网箱排名称</th>
			           <th>网箱数量</th>
			           <th>操作</th>
			        </tr>
			     </thead>
			     <tbody>
			     	<?php if(is_array($cage)): $i = 0; $__LIST__ = $cage;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$cage): $mod = ($i % 2 );++$i;?><tr>
				           <td><?php echo ($cage["cage_rowid"]); ?></td>
				           <td><?php echo ($cage["cage_rowname"]); ?></td>
				           <td><?php echo ($cage["cage_number"]); ?></td>
			               <td><button class="btn btn-danger" data-toggle="modal" data-target="#modifyCageModal" id="modifyCageButton" value="<?php echo ($cage["cage_id"]); ?>" onclick="cageChange(this)">修改</button></td>
				        </tr><?php endforeach; endif; else: echo "" ;endif; ?>    
			     </tbody>
	 		 </table>
	    </div> <!-- row --><hr><?php endif; ?>

<!-- modifyPool模态框（Modal） -->
<div class="modal fade" id="modifyPoolModal" tabindex="-1" role="dialog" 
   aria-labelledby="myModalLabel" aria-hidden="true">
		   <div class="modal-dialog">
		      <div class="modal-content">
		         <div class="modal-header">
		            <button type="button" class="close" 
		               data-dismiss="modal" aria-hidden="true">
		                  &times;
		            </button>
		            <h4 class="modal-title" id="myModalLabel">
		               信息修改
		            </h4>
		         </div>
		         <div class="modal-body">
		            <form action="<?php echo U('Home/Safe/modify', array('name' => 'pool'));?>" id="modifyPool_form"role="form" method="post">
		                <div class="form-group">
		            		<label for="">池塘名称</label>
		            		<input type="text" class="form-control" value="" name="pool_name" id="pool_name">
		            	</div>
		            	<div class="form-group">
		            		<label for="">池塘位置</label>
		            		<input type="text" class="form-control" value="" name="pool_addr" id="pool_addr">
		            	</div>
		            	<div class="form-group">
		            		<label for="">经纬度列表</label>
		            		<input type="text" class="form-control" value="" name="pool_coordinate" id="pool_coordinate">
		            	</div>
		            	<div class="form-group">
		            		<label for="">水面面积</label>
		            		<input type="text" class="form-control" value="" name="pool_area" id="pool_area" placeholder="水面面积，例如200平方米">
		            	</div>
		            	<div class="form-group">
		            		<label for="">水深</label>
		            		<input type="text" class="form-control" value="" name="pool_depth" id="pool_depth" placeholder="水深，例如100米">
		            	</div>
		            	<div class="form-group">
		            		<label for="">养殖设施设备</label>
		            		<input type="text" class="form-control" value="" name="pool_equipment" id="pool_equipment" placeholder="养殖设施设备">
		            	</div>
		            	<div class="form-group">
		            		<label for="">养殖模式</label>
		            		<select class="form-control"name="pool_model" id="pool_model">
		            			<option value="0">请选择养殖模式</option>
		            			<option value="大塘混养">大塘混养</option>
		            			<option value="网箱">网箱</option>
		            		</select>
		            	</div>
		            	<label class="control-label" for="input01" name="time">当前时间: <?php echo ($time); ?> </label>
		            	<div class="form-group" hidden>
		            		<input type="text" class="form-control" value="" name="pool_id" id="pool_id" >
		            	</div>

		            </form>
		         </div>
		         <div class="modal-footer">
		            <button type="button" class="btn btn-default" 
		               data-dismiss="modal">关闭
		            </button>
		            <button type="button"  id="modifyPoolBtn" class="btn btn-primary">
		               提交更改
		            </button>
		         </div>
		      </div><!-- /.modal-content -->
		</div><!-- /.modal -->
</div>
<!-- cage模态框（Modal） -->
<div class="modal fade" id="modifyCageModal" tabindex="-1" role="dialog" 
   aria-labelledby="myModalLabel" aria-hidden="true">
		   <div class="modal-dialog">
		      <div class="modal-content">
		         <div class="modal-header">
		            <button type="button" class="close" 
		               data-dismiss="modal" aria-hidden="true">
		                  &times;
		            </button>
		            <h4 class="modal-title" id="myModalLabel">
		               修改网箱信息
		            </h4>
		         </div>
		         <div class="modal-body">
		            <form action="<?php echo U('Home/Safe/modify', array('name' => 'Cage'));?>" id="modifyCage_form"role="form" method="post">
		            	
		            	<div class="form-group">
		            		<label for="">排编号</label>
		            		<input type="text" class="form-control" value="<?php echo ($cage["cage_rowid"]); ?>" name="cage_rowid" id="cage_rowid">
		            	</div>
		                <div class="form-group">
		            		<label for="">排名称</label>
		            		<input type="text" class="form-control" value="<?php echo ($cage["cage_rowname"]); ?>" name="cage_rowname" id="cage_rowname">
		            	</div>
		            	<div class="form-group">
		            		<label for="">网箱数量</label>
		            		<input type="text" class="form-control" value="<?php echo ($cage["cage_number"]); ?>" name="cage_number" id="cage_number">
		            	</div>
		            	<label class="control-label" for="input01" name="time">当前时间: <?php echo ($time); ?> </label>
		            	<div class="form-group" hidden>
		            		<input type="text" class="form-control" value="" name="cage_id" id="cage_id" >
		            	</div>
		            </form>
		         </div>
		         <div class="modal-footer">
		            <button type="button" class="btn btn-default" 
		               data-dismiss="modal">关闭
		            </button>
		            <button type="button"  id="modifyCageBtn" class="btn btn-primary">
		               提交更改
		            </button>
		         </div>
		      </div><!-- /.modal-content -->
		</div><!-- /.modal -->
</div>
<!-- 添加新网箱 -->
<div class="modal fade" id="addCageModal" tabindex="-1" role="dialog" 
   aria-labelledby="myModalLabel" aria-hidden="true">
		   <div class="modal-dialog">
		      <div class="modal-content">
		         <div class="modal-header">
		            <button type="button" class="close" 
		               data-dismiss="modal" aria-hidden="true">
		                  &times;
		            </button>
		            <h4 class="modal-title" id="myModalLabel">
		               添加网箱排
		            </h4>
		         </div>
		         <div class="modal-body">
		            <form action="<?php echo U('Home/Safe/adds', array('name' => 'cage'));?>" id="addCage_form"role="form" method="post">
		            	
		            	<div class="form-group">
		            		<label for="">排编号</label>
		            		<input type="text" class="form-control" value="" name="cage_rowid" id="cage_rowid">
		            	</div>
		                <div class="form-group">
		            		<label for="">排名称</label>
		            		<input type="text" class="form-control" value="" name="cage_rowname" id="cage_rowname">
		            	</div>
		            	<div class="form-group">
		            		<label for="">网箱数量</label>
		            		<input type="text" class="form-control" value="" name="cage_number" id="cage_number">
		            	</div>
		            	<label class="control-label" for="input01" name="time">当前时间: <?php echo ($time); ?> </label>
		            	
		            </form>
		         </div>
		         <div class="modal-footer">
		            <button type="button" class="btn btn-default" 
		               data-dismiss="modal">关闭
		            </button>
		            <button type="button"  id="addCageBtn" class="btn btn-primary">
		               提交
		            </button>
		         </div>
		      </div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>

    		</div>

	       <div class="col-sm-3">
	       	  
		       	  <h1><strong>导航元素</strong></h1>
				   	  <ul class="nav nav-pills nav-stacked">
				   	  	<li class="active"><a href="">功能一</a></li>
				   	  	<li><a href="">功能二</a></li>
				   	  	<li><a href="">功能三</a></li>
				   	  	<li><a href="">功能四</a></li>
				   	  </ul>
		      
	       </div>
	    </div> <!-- row -->
    	
   </div> <!-- container -->

   
    <footer class="footer">
      <div class="container">
        <p class="text-muted"><center>Copyright by 华南农业大学</center></p>
      </div>
    </footer>
    
  </body>
</html>

	<script>
	    function change(obj) { 
	       
			var val = $(obj).attr('value');
	        var url = "<?php echo U('Home/Safe/getChoose/name/pool/val/"+val+"');?>";
	        $.get(url, function(data, status){
	        	
	        	$('#pool_id').val(data['pool_id']);
	            $('#pool_name').val(data['pool_name']);
	            $('#pool_base_id').val(data['pool_base_id']);
	            $('#pool_addr').val(data['pool_addr']);
	            $('#pool_coordinate').val(data['pool_coordinate']);
	            $('#pool_area').val(data['pool_area']);
	            $('#pool_depth').val(data['pool_depth']);
	            $('#pool_equipment').val(data['pool_equipment']);
	            $('#pool_model').val(data['pool_model']);

	        });

	    } 
	     function cageChange(obj) { 
	       
			var val = $(obj).attr('value');
	        var url = "<?php echo U('Home/Safe/getChoose/name/cage/val/"+val+"');?>";
	        $.get(url, function(data, status){
	        	
	        	$('#cage_id').val(data['cage_id']);
	        	$('#cage_rowid').val(data['cage_rowid']);
	        	$('#cage_rowName').val(data['cage_rowname']);
	        	$('#cage_number').val(data['cage_number']);
	        });

	    } 
		$(document).ready(function(){
	       
	        $('#modifyCageBtn').click(function(){

	        	 var action= $('#modifyCage_form').attr('action');
	        	 var Formattr=$('#modifyCage_form').serialize();
		          console.log(Formattr);
	             $.post(action, Formattr,function(data,status) {
	                 
	                 if(status == "success") {
	                    alert( "修改成功！");
	                 }else{
	                 	alert("修改失败！");
	                 }
	                 setTimeout("window.location.href=\"<?php echo U('Home/Safe/index');?>\"",200);
	             });
	        });
	        $('#modifyPoolBtn').click(function(){

	        	 var action= $('#modifyPool_form').attr('action');
	        	 var Formattr=$('#modifyPool_form').serialize();
		         // console.log(Formattr);
	             $.post(action, Formattr,function(data,status) {
	                 
	                 if(status == "success") {
	                    alert( "修改成功！");
	                 }else{
	                 	alert("修改失败！");
	                 }
	                 setTimeout("window.location.href=\"<?php echo U('Home/Safe/index');?>\"",200);
	             });
	        });
	        $('#addCageBtn').click(function(){
	             var action = $('#addCage_form').attr('action');
	             var Formattr = $('#addCage_form').serialize();
	             $.post(action, Formattr, function(data,status) {
	                 if(status == "success") {
	                    alert( "添加成功！");
	                 }else{
	                 	alert("添加失败！");
	                 }
	                 setTimeout("window.location.href=\"<?php echo U('Home/Safe/index');?>\"",200);
	             });
	        });
		});
	     $(function () { $("[data-toggle='tooltip']").tooltip(); });
	</script>